import request from '@/config/axios'
import type { ShareData } from './types'

export const getShareListApi = (params: any): Promise<IResponse> => {
    const queryParams = params.queryParams ? params.queryParams : {}
    if (params.queryParams) {
        delete params.queryParams
    }
    Object.assign(params, queryParams)
    return request.get({ url: '/share/fx', params })
}

export const saveShareApi = (data: Partial<ShareData>): Promise<IResponse> => {
    return request.post({ url: '/share/folder', data })
}

export const delShareApi = (row: ShareData): Promise<IResponse> => {
    const data = {
        oper: row.oper, company_id: row.company_id, user_id: row.user_id,
        share_name: row.share_name, tar_company_id: row.tar_company_id, tar_user_id: row.tar_user_id
    }
    return request.post({ url: '/share/fx/del', data })
}

export const getFileListApi = (params: any): Promise<IResponse> => {
    return request.get({ url: '/file/list', params })
}